deltas: Handle untrusted checksums faster and more robustly
authorColin Walters <walters@verbum.org>
Mon, 11 Jul 2016 13:29:18 +0000 (09:29 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 29 Jul 2016 16:03:28 +0000 (16:03 +0000)
commit6ffcb24d227eae5a479caf45adb8037eceb6ae33
tree1b7960fb3982be067ab5ebb3bcf799695c839ff8
parentfb0bf27d100943311204c343d458f1fa9c3e6d65
deltas: Handle untrusted checksums faster and more robustly

When reworking the ostree core [to use O_TMPFILE](https://github.com/ostreedev/ostree/pull/369),
I hit an issue in the way the untrusted delta codepath ends up trying
to re-open the file to checksum it.  That's not possible with
`O_TMPFILE` since the fd (which we opened `O_WRONLY`) is the only
accessible reference to the content.

Fix this by changing the delta processing code to update a checksum as
we're doing writes, which is also faster, and ends up simplifying the
code as well.

What would be an even larger simplification here is if we e.g. used a
separate thread calling `write_object()` or something like that; the
main issue I see there is somehow bridging the fact that function
wants a `GInputStream*` but the delta code is generating stream of
writes.

Closes: #392
Approved by: jlebon
src/libostree/ostree-core-private.h
src/libostree/ostree-core.c
src/libostree/ostree-repo-commit.c
src/libostree/ostree-repo-private.h
src/libostree/ostree-repo-static-delta-processing.c